# 使用抽象类
# 工厂模式
from abc import ABCMeta,abstractmethod

class Employee(metaclass = ABCMeta):
	def __init__(self,name):
		self.name = name

	@abstractmethod
	def get_salary(self):
		"结算月薪（抽象方法）"
		pass


class Manager(Employee):
	"部门经理"
	def get_salary(self):
		return 12000


class Salesman(Employee):
	"销售员"
	def __init__(self,name,sales = 0.0):
		self.sales = sales
		super().__init__(name)

	def get_salary(self):
		return 1800.0 + self.sales * 0.05


class EmployeeFactory:
	"创建员工的工厂（工厂模式 - 通过工厂实现对象使用者和对象之间的解耦合）"
	@staticmethod
	def create(emp_type,*args,**kwargs):
		"创建员工"
		all_emp_type = {'M':Manager,'S':Salesman}
		cls = all_emp_type[emp_type.upper()]
		return cls(*args,**kwargs) if cls else None

def main():
	"主函数"
	emps = [
		EmployeeFactory.create('M','Smith'),
		EmployeeFactory.create('S','Cindy',12000),
		EmployeeFactory.create('S','Alice',60000)
	]

	for emp in emps:
		print(f'{emp.name}:{emp.get_salary():.2f}元')

if __name__ == '__main__':
	main()